
capture log close

set more off

use rep_final, clear


	
*******************************************************************************
*Table A2 - Panels A and B
	
* Mean
		
preserve

	keep if cit==0
	keep if marrinyr==2 & married==1 
	drop if citizen_sp==.	
	
	g post=0 if yrmarr<=2012
	replace post = 1 if (yrmarr>=2013 & yrmarr<=2016)
	replace post = 2 if (yrmarr>=2017)
	
	foreach gr of varlist daca controlgrdaca  {
		
				*******************************************************
				display ""
				display "--------------------------------------"
				
				display "Group: `gr' "
				
				display "--------------------------------------"
				**********************************************************
		
			estpost tabstat cit_sp native_sp citimm_sp if `gr'==1 [fweight=perwt], listwise ///
					by(post) statistics(mean sd) columns(statistics)
		
			esttab using tableA2_`gr'.csv, replace main(mean) aux(sd) nostar unstack nogaps nonote label
		
			}
restore

********************************************************************************
*Table A2 - Panel C
			
preserve
	keep if cit==0
	*married last year, currently married with or without spouse present
	keep if marrinyr==2 & (marst==1 | marst==2)

	*keep main treatment and control group
	keep if daca==1|controlgrdaca==1
	
	g spabsent=(marst==2)
	
	g post=0 if yrmarr<=2012
	replace post = 1 if (yrmarr>=2013 & yrmarr<=2016)
	replace post = 2 if (yrmarr>=2017)
	
	bys daca post: sum spabsent [fweight=perwt]	
	

		foreach gr of varlist daca controlgrdaca {
	
			*******************************************************
			display ""
			display "--------------------------------------"
			
			display "Group: `gr' "
			
			display "--------------------------------------"
			**********************************************************
	
		estpost tabstat spabsent if `gr'==1 [fweight=perwt], listwise ///
				by(post) statistics(mean) columns(statistics)
	
		esttab using tableA2-PanelC-`gr'.csv, replace main(mean) nostar unstack nogaps nonote label
	
		}
restore
